Regular expressions is a general term which covers the idea of pattern searching, typically in a string (or a vector of strings).
For now we'll learn about two useful functions for regular expressions and pattern searching (we'll go deeper into this topic in general later on):
grepl(), which returns a logical indicating if the pattern was found
grep(), which returns a vector of index locations of matching pattern instances
For both of these functions you'll pass in a pattern and then the object you want to search. Let's see some quick examples:
text <- "Hi there, do you know who you are voting for?"
grepl('voting',text)
grepl('Hi',text)
grepl('Sammy',text)
v <- c('a','b','c','d')
grep('a',v)
grep('c',v)
We'll learn more regular expression functions as we need them when doing exercises or projects. Want more info on regular expressions with R in the meantime? Check out this link